#include <stdio.h>

//题目:输入一个整数a,再输入两个整数p1,p2(p1,p2<32),
//输出该整数的二进制表示方法中从右端开始的p1到p2位.

void int2bin(int a)
{
    int mask = 0x80000000;
    for(int i = 0; i < 32; i++)
    {
        if((a & mask) == mask)
        printf("1");
        else
        printf("0");
        a = a << 1;
        if((i+1) % 4 == 0)
        printf(" ");
    }
    printf("\n");
}

int main()
{
    int a =  6;
    int p1 = 2, p2 = 4;
    int mask = ~0;
    mask = mask >> 4;
    // mask = mask << p1;
    int2bin(mask);
}